//
//  TableViewCell.m
//  YJ
//
//  Created by 吴志勇 on 2020/4/3.
//  Copyright © 2020 wzy. All rights reserved.
//

#import "TableViewCell.h"
#import <Masonry/Masonry.h>
#import "YJModel.h"

@implementation TableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}


- (void)setUI{
    self.label = [[UILabel alloc] init];
    self.label.numberOfLines = 0;
    [self.contentView addSubview:self.label];
//    self.label.preferredMaxLayoutWidth = [UIScreen mainScreen].bounds.size.width - 20;

    self.label.font = [UIFont systemFontOfSize:17];

    
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.left.mas_equalTo(10);
//        make.bottom.mas_equalTo(self.contentView.mas_bottom);
    }];
    
    UIView *view =[[UIView alloc] init];
    view.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.label.mas_bottom).mas_equalTo(10);
        make.left.mas_equalTo(10);
        make.height.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).mas_offset(-10);
    }];
    
    [super updateConstraints];
}

- (void)setModel:(YJModel *)model{
    _model = model;
    
    
}

- (void)setStr:(NSString *)str{
    _str = str;
    
//    self.label.text = str;
    
    if (str.length < 20) {
        self.label.text = @"";
        [self.label mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(600);
        }];
    }else{
        self.label.text = str;
    }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
